/*action create by pionner code builder*/
package com.pioneer.app.sms.log;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Transaction;

import com.opensymphony.xwork2.Action;

public class SmsSendLogAction implements Action, Serializable {

	// key
	private java.lang.Long sendLogId;

	private java.lang.Long[] sendLogIds;
	private SmsSendLog smssendlog;
	private java.lang.String content;
	private java.util.Date createTime;
	private java.lang.Long exNumber;
	private java.lang.Integer kind;
	private java.lang.Long messageFlag;
	private java.lang.String rptCode;
	private java.lang.String rptDesc;
	private java.util.Date rptTime;
	private java.util.Date sendTime;
	private java.lang.String toMobile;
	private java.util.Date updateTime;
	private java.lang.String title;
	private java.lang.String status;
	private List objects=null;
	private String condition=null;
	/** Ĭ�Ϲ��췽�� */
	public SmsSendLogAction(){
	}
	/** full constructor */
	public SmsSendLogAction(java.lang.String content,java.util.Date createTime,java.lang.Long exNumber,java.lang.Integer kind,java.lang.Long messageFlag,java.lang.String rptCode,java.lang.String rptDesc,java.util.Date rptTime,java.util.Date sendTime,java.lang.String toMobile,java.util.Date updateTime,java.lang.String title,java.lang.String statu){
		this.content=content;
		this.createTime=createTime;
		this.exNumber=exNumber;
		this.kind=kind;
		this.messageFlag=messageFlag;
		this.rptCode=rptCode;
		this.rptDesc=rptDesc;
		this.rptTime=rptTime;
		this.sendTime=sendTime;
		this.toMobile=toMobile;
		this.updateTime=updateTime;
		this.title=title;
		this.status=status;

	}
	public void setSendLogId(java.lang.Long sendLogId){
		this.sendLogId=sendLogId;
	}
	public java.lang.Long getSendLogId(){
		return sendLogId;
	}

	public void setSendLogIds(java.lang.Long[] sendLogIds){
		this.sendLogIds=sendLogIds;
	}
	public java.lang.Long[] getSendLogIds(){
		return sendLogIds;
	}

	public void setSmsSendLog(SmsSendLog smssendlog){
		this.smssendlog=smssendlog;
	}
	public SmsSendLog getSmsSendLog(){
		return smssendlog;
	}

	public void setContent(java.lang.String content){
		this.content=content;
	}
	public java.lang.String getContent(){
		return content;
	}

	public void setCreateTime(java.util.Date createTime){
		this.createTime=createTime;
	}
	public java.util.Date getCreateTime(){
		return createTime;
	}

	public void setExNumber(java.lang.Long exNumber){
		this.exNumber=exNumber;
	}
	public java.lang.Long getExNumber(){
		return exNumber;
	}

	public void setKind(java.lang.Integer kind){
		this.kind=kind;
	}
	public java.lang.Integer getKind(){
		return kind;
	}

	public void setMessageFlag(java.lang.Long messageFlag){
		this.messageFlag=messageFlag;
	}
	public java.lang.Long getMessageFlag(){
		return messageFlag;
	}

	public void setRptCode(java.lang.String rptCode){
		this.rptCode=rptCode;
	}
	public java.lang.String getRptCode(){
		return rptCode;
	}

	public void setRptDesc(java.lang.String rptDesc){
		this.rptDesc=rptDesc;
	}
	public java.lang.String getRptDesc(){
		return rptDesc;
	}

	public void setRptTime(java.util.Date rptTime){
		this.rptTime=rptTime;
	}
	public java.util.Date getRptTime(){
		return rptTime;
	}

	public void setSendTime(java.util.Date sendTime){
		this.sendTime=sendTime;
	}
	public java.util.Date getSendTime(){
		return sendTime;
	}

	public void setToMobile(java.lang.String toMobile){
		this.toMobile=toMobile;
	}
	public java.lang.String getToMobile(){
		return toMobile;
	}

	public void setUpdateTime(java.util.Date updateTime){
		this.updateTime=updateTime;
	}
	public java.util.Date getUpdateTime(){
		return updateTime;
	}

	public void setTitle(java.lang.String title){
		this.title=title;
	}
	public java.lang.String getTitle(){
		return title;
	}

	public void setStatus(java.lang.String status){
		this.status=status;
	}
	public java.lang.String getStatus(){
		return status;
	}

	public List getObjects() {
		return objects;
	}

	public void setObjects(List objects) {
		this.objects = objects;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String execute() throws Exception {
		return "SUCESS";
	}

	public String doList(){
		SmsSendLogDAO dao=new SmsSendLogDAO();
		this.objects=dao.findByCondition(condition);
		dao.getSession().close();
		return "list";
	}

	public String doAdd(){
		return "add";
	}

	public String doEdit(){
		SmsSendLogDAO dao=new SmsSendLogDAO();
		this.smssendlog=dao.findBySendLogId(sendLogId);
		dao.getSession().close();
		this.sedObj();;
		return "edit";
	}

	public String doSave(){
		Transaction tx=null;
		try {
			this.buildObj();
			SmsSendLogDAO dao=new SmsSendLogDAO();
			tx=dao.getSession().beginTransaction();
			if(null==this.smssendlog.getSendLogId()){
//			insert a new object
			//gave the object id by database 
				dao.add(smssendlog);
			}else{
//			update the object
				dao.getSession().clear();
				dao.update(smssendlog);
			}
			tx.commit();
			dao.getSession().close();
		} catch (Exception e) {
			tx.rollback();
			e.printStackTrace();
			return "error";
		}
		return "list";
	}

	public String doDetail(){
			SmsSendLogDAO dao=new SmsSendLogDAO();
		this.smssendlog=dao.findBySendLogId(sendLogId);
		dao.getSession().close();
		this.sedObj();;
		return "detail";
	}

	public String doDelete(){
		try{
			SmsSendLogDAO dao=new SmsSendLogDAO();
			dao.deleteObjs(sendLogIds);
			dao.getSession().clear();
			return "list";
		}catch(Exception e){
			return "error";
		}
	}

	private void buildObj(){
		this.smssendlog=new SmsSendLog();
		this.smssendlog.setSendLogId(this.sendLogId);
		this.smssendlog.setContent(this.content);
		this.smssendlog.setCreateTime(this.createTime);
		this.smssendlog.setExNumber(this.exNumber);
		this.smssendlog.setKind(this.kind);
		this.smssendlog.setMessageFlag(this.messageFlag);
		this.smssendlog.setRptCode(this.rptCode);
		this.smssendlog.setRptDesc(this.rptDesc);
		this.smssendlog.setRptTime(this.rptTime);
		this.smssendlog.setSendTime(this.sendTime);
		this.smssendlog.setToMobile(this.toMobile);
		this.smssendlog.setUpdateTime(this.updateTime);
		this.smssendlog.setTitle(this.title);
		this.smssendlog.setStatus(this.status);
	}
	private void sedObj(){

		if(null!=this.smssendlog){
			this.sendLogId=this.smssendlog.getSendLogId();
			this.content=this.smssendlog.getContent();
			this.createTime=this.smssendlog.getCreateTime();
			this.exNumber=this.smssendlog.getExNumber();
			this.kind=this.smssendlog.getKind();
			this.messageFlag=this.smssendlog.getMessageFlag();
			this.rptCode=this.smssendlog.getRptCode();
			this.rptDesc=this.smssendlog.getRptDesc();
			this.rptTime=this.smssendlog.getRptTime();
			this.sendTime=this.smssendlog.getSendTime();
			this.toMobile=this.smssendlog.getToMobile();
			this.updateTime=this.smssendlog.getUpdateTime();
			this.title=this.smssendlog.getTitle();
			this.status=this.smssendlog.getStatus();

		}
	}
}